<template>
  <div class="company-info-box company-info-a flexItems">
		<div class="company-info-photo flexColumn flexCenter font16" v-if="imgs1.length == 0">
			<p>{{$t('common.login.qy')}}</p>
			<p>{{$t('common.login.user')}}</p>
		</div>
    <div class="company-info-photo flexColumn flexCenter font16" v-else>
    	<img :src="this.$store.state.userInfo.path" alt="">
    </div>
		<div class="company-info-a-right">
			<div class="company-info-a-name flexBetween">
				<div class="flexItems">
					<span class="name">{{formData.enterpriseName}}</span>
					<img src="../assets/images/v-a.png" alt="" v-if="formData.status==2">
					<img src="../assets/images/v-b.png" alt="" v-else>
          <!-- 1-未认证，2-认证审核中，3-已认证,4-认证为未通过 -->
					<span class="renzheng renzhengOn" v-if="formData.status==3">{{$t('common.company.Certified')}}</span>
					<span class="renzheng" v-else-if="formData.status==2">{{$t('common.company.notCertified1')}}</span>
					<span class="renzheng" v-else>{{$t('common.company.notCertified')}}</span>
				</div>
        <!-- 立即认证 -->
				<router-link class="red1" to="/vip/c_authen?type=1" v-if="(formData.status == 1 || formData.status == 4) && showRZ">{{$t('common.company.certification')}}</router-link>
			</div>
			<div class="company-info-a-write flexItems">
				<span class="font14" >{{$t('common.company.enterpriseInfo')}}</span>
        <span v-if="formData.completionRate">{{formData.completionRate}}%</span>
				<router-link to="/vip/c_authen?type=0" class="wanshanInfo">
					<i class="el-icon-edit-outline"></i>{{$t('common.company.improveInfo')}}
				</router-link>
			</div>
		</div>
	</div>
</template>
<script>
// let log = console.log
import {ajaxAdd} from '@/utils/js.js'
import { details } from '@/services/api.js';
export default {
  name:'info',
  props:{
    showRZ:{type:Boolean,default:false}
  },
  data(){
    return {
      type:'',  //0-完善信息，1-完善信息+申请认证
				uploadFile:'/recruit-portal-api/v1/common/uploadFile',
				imgUrl:this.$store.state.imgUrl,
				imgs1:'',
				imgs2:'',
				
				corporateTypeList:[],
				
				inputVisible: false,
				inputValue: '',
				dialogVisible: false, //提交弹框
				enterpriseTagList:[], //企业标签
				productTagList:[],//产品标签

				labelList:[],//选中的标签
				pup:false,
				pupType:2,
				submitTip:false,
				qyLabe:[],
				cpCurId:0,  //选择的认证id

				formData:{
					corporateType:'',	//企业类型/企业性质
					enterpriseInfo	:'',	//企业信息/经营范围
					enterpriseName	:'',	//企业名称
					enterpriseProfile	:'',	//企业简介
					enterpriseTag	:'',	//企业标签
					establishmentDate	:'',	//成立日期
					id	:'',	//企业信息ID
					ipcount:'',	//知识产权数量
					lawPerson	:'',	//法人代表
					logoId	:'',	//企业LOGO附件ID
					registeredCapital	:'',	//注册资本
					staffNumber	:'',	//员工人数
					status	:'',	//是否发起认证 1不发起认证，2发起认证
					uscc	:'',	//统一社会信用代码，
          address:'', //公司地址
          industryTxt:'',
					// 企业资质
					qualificationInformationList:[
						{
							attachment:{}, // 附件信息
							erId:'', //企业资源主键
							id:'', //	主键
							name	:'', //企业资质名称
							status	:'', //企业资质状态 1,未认证，2已认证
						}
					],
					technologyDirectionList:[],	//	核心技术与产品方向	
				},
				submitTip_text:{}, // 弹窗提示
				single:{
					description:'',	//核心技术或产品描述
					erId	:'',	//企业资源主键
					id	:0,	//主键
					name	:'',	//核心技术或产品名称
					technologyTag	:[],	//产品标签,
				},
				perfectEnterpriseInfoData:{}, //完善信息的数据
      
    } 
  },
  computed:{
   
  },
  watch:{
    '$i18n.locale'() {
			this.content();
		}
  },
  mounted(){
    this.content()
    console.log('info1111111111111111111')
  },
  // ******************* methods 开始 ****************** //
  methods:{
    content(){
      ajaxAdd(this,details,{},res=>{
        let data = res.data
        console.log('企业信息',data)
        if(data){
          let formData = this.formData
          let productTagListed = []
          //产品标签显示
					if(data.productTag){
						let productTagList = data.productTag.split(',')
            let productTagListTxt = data.productTagTxt.split(',')
            
						for(let i = 0; i < productTagList.length; i++){
							productTagListed = productTagListed.concat({text:productTagListTxt[i],value:productTagList[i]})
						}
					}
          //企业标签显示
          let arry = []
          if(data.enterpriseTag && data.enterpriseTag.length>0){
            let enterpriseTag = data.enterpriseTag.split(',')
            let enterpriseTagTxt = data.enterpriseTagTxt.split(',')
            for(let i=0;i<enterpriseTag.length;i++){
              arry = arry.concat({text:enterpriseTagTxt[i],value:enterpriseTag[i]})
            }
          }
          
          this.qyLabe = arry
          formData.corporateType=data.corporateType;	//企业类型/企业性质
          formData.enterpriseInfo	=data.enterpriseInfo;	//企业信息/经营范围
          formData.enterpriseName	=data.enterpriseName;	//企业名称
          formData.enterpriseProfile=data.enterpriseProfile;	//企业简介
          formData.enterpriseTag=data.enterpriseTag;	//企业标签
          formData.establishmentDate=data.establishmentDate;	//成立日期
          formData.id=data.id;	//企业信息ID
          formData.ipcount=data.ipcount;	//知识产权数量
          formData.lawPerson=data.lawPerson;	//法人代表
          formData.industryTxt=data.industryTxt;	//法人代表
          
          for(let i=0;i<data.attachmentList.length;i++){
            if(data.attachmentList[i].belongType == 1){
              formData.logoId = data.attachmentList[i].id
              this.imgs1 = this.imgUrl+data.attachmentList[i].path
            }
          }
          formData.registeredCapital=data.registeredCapital;	//注册资本
          formData.staffNumber=data.staffNumber;	//员工人数
          formData.staffNumberTxt=data.staffNumberTxt;	//员工人数1
          
          formData.status=data.status;	//是否发起认证 1不发起认证，2发起认证
          formData.uscc=data.uscc;	//统一社会信用代码
          // 企业资质
          if(data.qualificationInformationList.length == 0){
            formData.qualificationInformationList = this.formData.qualificationInformationList 
          }else{
            formData.qualificationInformationList=data.qualificationInformationList
            data.qualificationInformationList[0].attachment ? this.imgs2 = this.imgUrl+data.qualificationInformationList[0].attachment.path : this.imgs2 = ''
          }
          formData.completionRate = data.completionRate
          formData.lawPerson = data.lawPerson
          formData.address = data.address
          formData.technologyDirectionList = data.technologyDirectionList
          this.formData = formData
          this.$emit('userInfoChange',{formData:formData,imgs1:this.imgs1,imgs2:this.imgs2,detail:data,qyLabe:this.qyLabe,productTagListed:productTagListed})
        }
      })
    },
  }
  // ******************** methods结束 ***************** //
}
</script>

<style lang="scss">
  .company-info-photo img{width:100%;height: 100%;object-fit: cover;}
</style>